package com.zoe.onelink.test.container.support.ctr.impl;

import com.zoe.onelink.test.container.support.ctr.init.ContainerEnvironmentInitializer;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.DockerImageName;

/**
 * <p>标题: </p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2023</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2023-01-15
 */
public class RedisContainer extends GenericContainer<RedisContainer> implements ContainerEnvironmentInitializer {

    public RedisContainer(String dockerImageName) {
        super(DockerImageName.parse(dockerImageName));
    }

    @Override
    public void preStart() {
        this.addExposedPort(6379);
    }

    @Override
    public void afterStarted() {
        System.setProperty("spring.redis.port", this.getMappedPort(6379).toString());
    }
}
